package com.xyh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * TODO
 *
 * @author 丁德成
 * @explain
 * @date 2023/4/12
 */
@Configuration
@EnableSwagger2//开启swagger注解驱动
public class SwaggerConfig {
    @Bean//把方法返回的数据对象 交与spring容器管理
    public Docket docket() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2).groupName("Marie.rose")
                .apiInfo(getInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xyh.controller"))//只为com.xyh.controller包下的类生成接口文档
                .build();
        return docket;
    }

    private ApiInfo getInfo() {
        Contact DEFAULT_CONTACT = new Contact("威廉.伯金", "http://www.aaa.com", "111@qq.com");
        ApiInfo apiInfo = new ApiInfo("G病毒", "G病毒", "6.6.6", "https://www.jd.com",
                DEFAULT_CONTACT, "Umbrella Corporation", "http://www.aaa.com", new ArrayList<VendorExtension>());
        return apiInfo;
    }

}
